package com.lifeng.controller;

import com.lifeng.service.dto.UserDTO;
import com.lifeng.service.exception.BizException;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;


/**
 * Created by lifeng on 2018/4/13.
 * 服务提供方
 */
@RestController
public class UserProviderCotroller {
    @RequestMapping("/save")
    public Map<String,Object> save(@RequestBody UserDTO userDto){
        Map<String,Object> map = new HashMap<>();
        map.put("userId",userDto.getUserId());
        map.put("userName",userDto.getUserName());
        map.put("age",userDto.getAge());
        map.put("birthday",userDto.getBirthday());
        return map;
    }

    @RequestMapping("/add")
    public Map<String,Object> add(@RequestBody UserDTO userDto) throws BizException {
        Map<String,Object> map = new HashMap<>();
        map.put("userId",userDto.getUserId());
        map.put("userName",userDto.getUserName());
        map.put("age",userDto.getAge());
        map.put("birthday",userDto.getBirthday());

        try{
            int i = 1/0;
        }catch(Exception e){
            throw new BizException("123456","系统异常");
        }
        return map;
    }
}
